<div class="content_filtro">
    <div class="filtro">
        <form id="form_filtro" method="get" action="">
            <i>Pesquisar</i>
            
            <label><?php echo elemform::radio('stafiltro','stafiltro','1',$this->stafiltro); ?> Ativo</label>
            <label><?php echo elemform::radio('stafiltro','stafiltro','0',$this->stafiltro); ?> Inativo</label>
            
            <input type="text" name="dscfiltro" placeholder="Aluno" value="<?php echo $this->dscfiltro; ?>" />

            <input type="submit" class="btn-pdr" name="buscar" value="buscar" />
        </form>
    </div>
    <?php if($this->per_add){?>
    <div class="content-btn">
        <span>Nova Matricula</span><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit')); ?>">+</a>
    </div>
    <?php } ?>
</div>

<div class="content-list">
    
    <h2><?php echo $this->titulo;?></h2>
    
    <table id="tlist">
        <thead>
            <tr>
                <th>Número</th>
                <th>Nome do Aluno</th>
                <th>Data</th>
                <th>Grupo</th>
                <th>Curso</th>
                <th width="50px">Semestre</th>
                <th width="50px">Ano</th>
                <th class="bc">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($this->result as $row) { 
                
                $query = 'SELECT SQL_CACHE cb.CBS_NOM, n.NRT_NOM, c.CUR_SEM, c.CUR_ANO '
                        . 'FROM CURSO c, CURSOBASE cb, NUMEROTURMA n '
                        . 'WHERE c.CBS_ID = cb.CBS_ID AND c.CUR_TRM = n.NRT_ID AND c.CUR_ID = '.$row['CUR_ID'];
                $cur = $this->db->fetchRow($query);
                
                $cancelar = true;
                
                $query = 'SELECT SQL_CACHE PAR_NUM FROM PARCELAMENTO WHERE MAT_ID = '.$row['MAT_ID'].' and PAR_STAPGO = 0';
                $pars = $this->db->fetchRow($query);
                if($pars['PAR_NUM'] > 0) $cancelar = false;
                
                ?>
                <tr>  
                    <td><?php echo $row['MAT_ID']; ?></td>
                    <td><?php echo $row['ALU_NOM']; ?></td>
                    <td><?php echo Datetools::invertDH_D($row['MAT_DATHOR']); ?></td>
                    <td><?php echo $cur['NRT_NOM']; ?></td>
                    <td><?php echo $cur['CBS_NOM']; ?></td>
                    <td><?php echo dominio::getSemestres($cur['CUR_SEM']); ?></td>
                    <td><?php echo $cur['CUR_ANO']; ?></td>
                    <td class="bc">
                        <?php /* if($this->per_edt){?><a class="btn-bar-list" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'boleto', 'id' => $row->CUR_ID)); ?>" target="_blank">Boleto</a><?php } */ ?>
                        <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => 'parcelamento', 'action' => 'index', 'mat_id' => $row['MAT_ID'])); ?>">Pagamento</a><?php }?>
                        <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['MAT_ID'])); ?>">Editar</a><?php }?>
                        <?php if($this->per_del && $cancelar == true){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'delete', 'id' => $row['MAT_ID'])); ?>" >Desativar</a><?php } ?> 
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>